package com.mydomain.Bodega;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;

@Name("grup")
@Scope(ScopeType.APPLICATION)
public class GrupLista {

	@DataModelSelection
	@Out(required = false)
	@In(required = false)
	private InvGrupo SelectGrupo;

	@DataModel
	private List<InvGrupo> list = new ArrayList();
	
	@In(create = true)
	EntityManager entityManager;

	/**
	 * Metodo que retonar el litado de grupos 
	 * @return liistado de grupos de inventario
	 */
	@Factory("list")
	public List<InvGrupo> getList() {

		Query query = entityManager.createQuery("Select  g  from InvGrupo g");
		list = query.getResultList();
		return list;
	}
	
}
